"""
点击早餐并关注
"""

from appium import webdriver
from time import  sleep
from  selenium.webdriver.common.by import By
import time

desired_capabilities={
    'platformName':'Android',
    'platformVersion':'7.1.2',
    'deviceName':'127.0.0.1:62001',
    'appPackage':'com.gfeng.daydaycook',
    'appActivity':'com.gfeng.daydaycook.activity.WelcomeActivity',
    'noReset':True,
    'newCommandTimeout':60,
    'unicodeKeyboard':True,
    'resetKeyboard':True
}
screen_name=time.strftime('%Y%m%d_%H%M%S')
driver=webdriver.Remote('http://localhost:4723/wd/hub',desired_capabilities)
driver.implicitly_wait(30)

#数据
sjh='18380260656'
#定位器

zc_locator = (By.ID,'com.gfeng.daydaycook:id/tv_breakfast')
djcm_locator = (By.XPATH,'//android.support.v7.widget.RecyclerView[@resource-id=\"com.gfeng.daydaycook:id/rv_daily\"]/android.widget.LinearLayout[1]')
djgz_locator = (By.ID,'com.gfeng.daydaycook:id/iv_focus_status')
input_locator = (By.ID,'com.gfeng.daydaycook:id/telEdit')
btn_locator = (By.ID,'com.gfeng.daydaycook:id/verifyTv')

#点击早餐
driver.find_element(*zc_locator).click()
#点击紫薯
driver.find_element(*djcm_locator).click()
#点击关注
driver.find_element(*djgz_locator).click()
#点击输入框
driver.find_element(*input_locator).click()
driver.find_element(*input_locator).send_keys(sjh)
#点击验证码
driver.find_element(*btn_locator).click()
#点击刷性
window_size = driver.get_window_size()
driver.swipe(window_size['width']/2,window_size['height']/3*2,window_size['width']/2,window_size['height']/3*1,1000)
sleep(2)